package cc.prayol.permission.mapper.auth;

import static cc.prayol.permission.mapper.auth.DictDataDynamicSqlSupport.*;
import static org.mybatis.dynamic.sql.SqlBuilder.*;

import cc.prayol.permission.entity.auth.DictData;
import java.util.List;
import java.util.Optional;
import javax.annotation.Generated;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import org.mybatis.dynamic.sql.BasicColumn;
import org.mybatis.dynamic.sql.delete.DeleteDSLCompleter;
import org.mybatis.dynamic.sql.delete.render.DeleteStatementProvider;
import org.mybatis.dynamic.sql.insert.render.InsertStatementProvider;
import org.mybatis.dynamic.sql.select.CountDSLCompleter;
import org.mybatis.dynamic.sql.select.SelectDSLCompleter;
import org.mybatis.dynamic.sql.select.render.SelectStatementProvider;
import org.mybatis.dynamic.sql.update.UpdateDSL;
import org.mybatis.dynamic.sql.update.UpdateDSLCompleter;
import org.mybatis.dynamic.sql.update.UpdateModel;
import org.mybatis.dynamic.sql.update.render.UpdateStatementProvider;
import org.mybatis.dynamic.sql.util.SqlProviderAdapter;
import org.mybatis.dynamic.sql.util.mybatis3.MyBatis3Utils;

@Mapper
public interface DictDataMapper {
    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.59+08:00", comments="Source Table: sys_dict_data")
    BasicColumn[] selectList = BasicColumn.columnList(dictCode, dictSort, dictLabel, dictValue, dictType, cssClass, listClass, isDefault, status, createBy, createTime, updateBy, updateTime, remark);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.589+08:00", comments="Source Table: sys_dict_data")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    long count(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.589+08:00", comments="Source Table: sys_dict_data")
    @DeleteProvider(type=SqlProviderAdapter.class, method="delete")
    int delete(DeleteStatementProvider deleteStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.589+08:00", comments="Source Table: sys_dict_data")
    @InsertProvider(type=SqlProviderAdapter.class, method="insert")
    int insert(InsertStatementProvider<DictData> insertStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.589+08:00", comments="Source Table: sys_dict_data")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @ResultMap("DictDataResult")
    Optional<DictData> selectOne(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.59+08:00", comments="Source Table: sys_dict_data")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @Results(id="DictDataResult", value = {
        @Result(column="dict_code", property="dictCode", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="dict_sort", property="dictSort", jdbcType=JdbcType.INTEGER),
        @Result(column="dict_label", property="dictLabel", jdbcType=JdbcType.VARCHAR),
        @Result(column="dict_value", property="dictValue", jdbcType=JdbcType.VARCHAR),
        @Result(column="dict_type", property="dictType", jdbcType=JdbcType.VARCHAR),
        @Result(column="css_class", property="cssClass", jdbcType=JdbcType.VARCHAR),
        @Result(column="list_class", property="listClass", jdbcType=JdbcType.VARCHAR),
        @Result(column="is_default", property="isDefault", jdbcType=JdbcType.CHAR),
        @Result(column="status", property="status", jdbcType=JdbcType.CHAR),
        @Result(column="create_by", property="createBy", jdbcType=JdbcType.VARCHAR),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="update_by", property="updateBy", jdbcType=JdbcType.VARCHAR),
        @Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="remark", property="remark", jdbcType=JdbcType.VARCHAR)
    })
    List<DictData> selectMany(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.59+08:00", comments="Source Table: sys_dict_data")
    @UpdateProvider(type=SqlProviderAdapter.class, method="update")
    int update(UpdateStatementProvider updateStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.59+08:00", comments="Source Table: sys_dict_data")
    default long count(CountDSLCompleter completer) {
        return MyBatis3Utils.countFrom(this::count, dictData, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.59+08:00", comments="Source Table: sys_dict_data")
    default int delete(DeleteDSLCompleter completer) {
        return MyBatis3Utils.deleteFrom(this::delete, dictData, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.59+08:00", comments="Source Table: sys_dict_data")
    default int deleteByPrimaryKey(Long dictCode_) {
        return delete(c -> 
            c.where(dictCode, isEqualTo(dictCode_))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.59+08:00", comments="Source Table: sys_dict_data")
    default int insert(DictData record) {
        return MyBatis3Utils.insert(this::insert, record, dictData, c ->
            c.map(dictCode).toProperty("dictCode")
            .map(dictSort).toProperty("dictSort")
            .map(dictLabel).toProperty("dictLabel")
            .map(dictValue).toProperty("dictValue")
            .map(dictType).toProperty("dictType")
            .map(cssClass).toProperty("cssClass")
            .map(listClass).toProperty("listClass")
            .map(isDefault).toProperty("isDefault")
            .map(status).toProperty("status")
            .map(createBy).toProperty("createBy")
            .map(createTime).toProperty("createTime")
            .map(updateBy).toProperty("updateBy")
            .map(updateTime).toProperty("updateTime")
            .map(remark).toProperty("remark")
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.59+08:00", comments="Source Table: sys_dict_data")
    default int insertSelective(DictData record) {
        return MyBatis3Utils.insert(this::insert, record, dictData, c ->
            c.map(dictCode).toPropertyWhenPresent("dictCode", record::getDictCode)
            .map(dictSort).toPropertyWhenPresent("dictSort", record::getDictSort)
            .map(dictLabel).toPropertyWhenPresent("dictLabel", record::getDictLabel)
            .map(dictValue).toPropertyWhenPresent("dictValue", record::getDictValue)
            .map(dictType).toPropertyWhenPresent("dictType", record::getDictType)
            .map(cssClass).toPropertyWhenPresent("cssClass", record::getCssClass)
            .map(listClass).toPropertyWhenPresent("listClass", record::getListClass)
            .map(isDefault).toPropertyWhenPresent("isDefault", record::getIsDefault)
            .map(status).toPropertyWhenPresent("status", record::getStatus)
            .map(createBy).toPropertyWhenPresent("createBy", record::getCreateBy)
            .map(createTime).toPropertyWhenPresent("createTime", record::getCreateTime)
            .map(updateBy).toPropertyWhenPresent("updateBy", record::getUpdateBy)
            .map(updateTime).toPropertyWhenPresent("updateTime", record::getUpdateTime)
            .map(remark).toPropertyWhenPresent("remark", record::getRemark)
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.59+08:00", comments="Source Table: sys_dict_data")
    default Optional<DictData> selectOne(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectOne(this::selectOne, selectList, dictData, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.59+08:00", comments="Source Table: sys_dict_data")
    default List<DictData> select(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectList(this::selectMany, selectList, dictData, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.59+08:00", comments="Source Table: sys_dict_data")
    default List<DictData> selectDistinct(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectDistinct(this::selectMany, selectList, dictData, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.59+08:00", comments="Source Table: sys_dict_data")
    default Optional<DictData> selectByPrimaryKey(Long dictCode_) {
        return selectOne(c ->
            c.where(dictCode, isEqualTo(dictCode_))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.59+08:00", comments="Source Table: sys_dict_data")
    default int update(UpdateDSLCompleter completer) {
        return MyBatis3Utils.update(this::update, dictData, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.59+08:00", comments="Source Table: sys_dict_data")
    static UpdateDSL<UpdateModel> updateAllColumns(DictData record, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(dictCode).equalTo(record::getDictCode)
                .set(dictSort).equalTo(record::getDictSort)
                .set(dictLabel).equalTo(record::getDictLabel)
                .set(dictValue).equalTo(record::getDictValue)
                .set(dictType).equalTo(record::getDictType)
                .set(cssClass).equalTo(record::getCssClass)
                .set(listClass).equalTo(record::getListClass)
                .set(isDefault).equalTo(record::getIsDefault)
                .set(status).equalTo(record::getStatus)
                .set(createBy).equalTo(record::getCreateBy)
                .set(createTime).equalTo(record::getCreateTime)
                .set(updateBy).equalTo(record::getUpdateBy)
                .set(updateTime).equalTo(record::getUpdateTime)
                .set(remark).equalTo(record::getRemark);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.59+08:00", comments="Source Table: sys_dict_data")
    static UpdateDSL<UpdateModel> updateSelectiveColumns(DictData record, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(dictCode).equalToWhenPresent(record::getDictCode)
                .set(dictSort).equalToWhenPresent(record::getDictSort)
                .set(dictLabel).equalToWhenPresent(record::getDictLabel)
                .set(dictValue).equalToWhenPresent(record::getDictValue)
                .set(dictType).equalToWhenPresent(record::getDictType)
                .set(cssClass).equalToWhenPresent(record::getCssClass)
                .set(listClass).equalToWhenPresent(record::getListClass)
                .set(isDefault).equalToWhenPresent(record::getIsDefault)
                .set(status).equalToWhenPresent(record::getStatus)
                .set(createBy).equalToWhenPresent(record::getCreateBy)
                .set(createTime).equalToWhenPresent(record::getCreateTime)
                .set(updateBy).equalToWhenPresent(record::getUpdateBy)
                .set(updateTime).equalToWhenPresent(record::getUpdateTime)
                .set(remark).equalToWhenPresent(record::getRemark);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.59+08:00", comments="Source Table: sys_dict_data")
    default int updateByPrimaryKey(DictData record) {
        return update(c ->
            c.set(dictSort).equalTo(record::getDictSort)
            .set(dictLabel).equalTo(record::getDictLabel)
            .set(dictValue).equalTo(record::getDictValue)
            .set(dictType).equalTo(record::getDictType)
            .set(cssClass).equalTo(record::getCssClass)
            .set(listClass).equalTo(record::getListClass)
            .set(isDefault).equalTo(record::getIsDefault)
            .set(status).equalTo(record::getStatus)
            .set(createBy).equalTo(record::getCreateBy)
            .set(createTime).equalTo(record::getCreateTime)
            .set(updateBy).equalTo(record::getUpdateBy)
            .set(updateTime).equalTo(record::getUpdateTime)
            .set(remark).equalTo(record::getRemark)
            .where(dictCode, isEqualTo(record::getDictCode))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.59+08:00", comments="Source Table: sys_dict_data")
    default int updateByPrimaryKeySelective(DictData record) {
        return update(c ->
            c.set(dictSort).equalToWhenPresent(record::getDictSort)
            .set(dictLabel).equalToWhenPresent(record::getDictLabel)
            .set(dictValue).equalToWhenPresent(record::getDictValue)
            .set(dictType).equalToWhenPresent(record::getDictType)
            .set(cssClass).equalToWhenPresent(record::getCssClass)
            .set(listClass).equalToWhenPresent(record::getListClass)
            .set(isDefault).equalToWhenPresent(record::getIsDefault)
            .set(status).equalToWhenPresent(record::getStatus)
            .set(createBy).equalToWhenPresent(record::getCreateBy)
            .set(createTime).equalToWhenPresent(record::getCreateTime)
            .set(updateBy).equalToWhenPresent(record::getUpdateBy)
            .set(updateTime).equalToWhenPresent(record::getUpdateTime)
            .set(remark).equalToWhenPresent(record::getRemark)
            .where(dictCode, isEqualTo(record::getDictCode))
        );
    }
}